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

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

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

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

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

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

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

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

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

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

c.t = a
k.p = g
k.v = g
k.r = g
k.y = l
l.p = c
l.r = g
f.z = d
f.p = m
f.w = k
d.z = m
d.p = f
d.w = g
m.z = f
m.p = f
m.w = k
g.p = k
g.v = k
g.r = k
g.y = i
a.t = c
i.p = a
i.r = k
assert f.w.y.r.txt == "g"