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

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: C = None
        self.z: C = None
        self.s: C = None
        self.txt = txt

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

c = A("c")
h = B("h")
g = C("g")
f = D("f")
j = D("j")
k = A("k")
n = D("n")
d = C("d")
m = B("m")

c.t = d
c.y = k
h.y = g
h.q = f
h.x = d
g.p = d
g.w = d
g.z = d
g.s = d
f.y = g
f.r = n
j.y = d
j.r = n
k.t = d
k.y = c
n.y = g
n.r = j
d.p = g
d.w = g
d.z = g
d.s = g
m.y = g
m.x = g
m.q = j
assert c.t.s.w.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: C = None
        self.z: C = None
        self.s: C = None
        self.txt = txt

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

c = A("c")
h = B("h")
g = C("g")
f = D("f")
j = D("j")
k = A("k")
n = D("n")
d = C("d")
m = B("m")

c.t = d
c.y = k
h.y = g
h.q = f
h.x = d
g.p = d
g.w = d
g.z = d
g.s = d
f.y = g
f.r = n
j.y = d
j.r = n
k.t = d
k.y = c
n.y = g
n.r = j
d.p = g
d.w = g
d.z = g
d.s = g
m.y = g
m.x = g
m.q = j
assert c.t.s.w.s.p.txt == "d"