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

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: F = None
        self.s: B = None
        self.z: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.o: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: E = None
        self.s: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: F = None
        self.s: B = None
        self.z: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.o: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: E = None
        self.s: C = None
        self.txt = txt

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

g.q = m
j.y = m
j.r = d
d.o = j
d.z = j
m.u = d
m.q = e
m.s = j
m.z = b
h.u = d
h.o = g
b.z = g
b.x = h
b.s = d
e.z = g
e.x = h
e.s = d
f.u = d
f.o = g
assert h.u.z.r.o.y.q.txt == "e"