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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: D = None
        self.q: B = None
        self.u: B = None
        self.txt = txt

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

k = A("k")
b = B("b")
c = C("c")
j = D("j")
h = E("h")
n = F("n")
d = A("d")

k.u = c
b.r = c
b.p = d
c.y = h
c.s = h
c.u = h
j.o = h
j.p = c
h.r = c
h.t = j
h.q = b
h.u = b
n.v = b
n.s = j
n.y = j
d.u = c
assert d.u.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: D = None
        self.q: B = None
        self.u: B = None
        self.txt = txt

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

k = A("k")
b = B("b")
c = C("c")
j = D("j")
h = E("h")
n = F("n")
d = A("d")

k.u = c
b.r = c
b.p = d
c.y = h
c.s = h
c.u = h
j.o = h
j.p = c
h.r = c
h.t = j
h.q = b
h.u = b
n.v = b
n.s = j
n.y = j
d.u = c
assert d.u.s.r.txt == "c"