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

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

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

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

i = A("i")
d = B("d")
h = C("h")
f = D("f")
k = C("k")
m = B("m")
l = A("l")
c = D("c")

i.r = k
d.r = f
d.q = h
d.w = h
h.y = d
f.t = h
f.z = d
f.r = k
k.y = m
m.r = c
m.q = h
m.w = k
l.r = k
c.t = k
c.r = k
c.z = m
assert f.t.y.w.y.q.y.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

i = A("i")
d = B("d")
h = C("h")
f = D("f")
k = C("k")
m = B("m")
l = A("l")
c = D("c")

i.r = k
d.r = f
d.q = h
d.w = h
h.y = d
f.t = h
f.z = d
f.r = k
k.y = m
m.r = c
m.q = h
m.w = k
l.r = k
c.t = k
c.r = k
c.z = m
assert f.t.y.w.y.q.y.r.r.txt == "k"