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

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

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

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

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

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

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

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

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

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

f.p = i
f.y = k
m.r = f
i.q = k
i.w = c
i.u = d
d.w = c
d.z = c
d.s = k
c.w = d
c.z = d
c.s = k
k.q = i
k.w = d
k.u = d
assert d.s.q.w.txt == "c"