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

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

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

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

c = A("c")
g = B("g")
b = C("b")
l = D("l")
f = A("f")
n = D("n")
j = C("j")

c.r = l
g.r = j
g.w = j
g.u = f
g.o = n
b.p = f
b.t = c
l.z = g
l.o = n
f.r = n
n.z = g
n.o = l
j.p = f
j.t = f
assert g.r.t.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
b = C("b")
l = D("l")
f = A("f")
n = D("n")
j = C("j")

c.r = l
g.r = j
g.w = j
g.u = f
g.o = n
b.p = f
b.t = c
l.z = g
l.o = n
f.r = n
n.z = g
n.o = l
j.p = f
j.t = f
assert g.r.t.r.z.r.txt == "j"