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

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

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

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

m = A("m")
n = B("n")
j = C("j")
i = D("i")
g = B("g")
b = D("b")
f = A("f")

m.u = n
n.q = j
n.u = j
n.o = m
j.y = b
i.o = j
i.r = j
i.u = n
g.q = j
g.u = j
g.o = m
b.o = j
b.r = j
b.u = g
f.u = g
assert i.r.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
j = C("j")
i = D("i")
g = B("g")
b = D("b")
f = A("f")

m.u = n
n.q = j
n.u = j
n.o = m
j.y = b
i.o = j
i.r = j
i.u = n
g.q = j
g.u = j
g.o = m
b.o = j
b.r = j
b.u = g
f.u = g
assert i.r.y.r.y.txt == "b"