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

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

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

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

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

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

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

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

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

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

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