class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.v: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: E = None
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: A = None
        self.s: B = None
        self.w: D = None
        self.txt = txt

b = A("b")
g = B("g")
n = C("n")
j = D("j")
m = E("m")
f = F("f")
i = B("i")
d = A("d")
e = E("e")

b.r = j
g.o = j
g.v = n
n.z = j
n.p = m
n.y = b
j.u = f
m.p = f
m.q = n
f.v = d
f.s = g
f.w = j
i.o = j
i.v = n
d.r = j
e.p = f
e.q = n
assert b.r.u.s.o.u.w.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.v: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: E = None
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: A = None
        self.s: B = None
        self.w: D = None
        self.txt = txt

b = A("b")
g = B("g")
n = C("n")
j = D("j")
m = E("m")
f = F("f")
i = B("i")
d = A("d")
e = E("e")

b.r = j
g.o = j
g.v = n
n.z = j
n.p = m
n.y = b
j.u = f
m.p = f
m.q = n
f.v = d
f.s = g
f.w = j
i.o = j
i.v = n
d.r = j
e.p = f
e.q = n
assert b.r.u.s.o.u.w.u.s.txt == "g"