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

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

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

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

b = A("b")
m = B("m")
l = C("l")
n = D("n")
f = B("f")
e = D("e")

b.y = f
b.p = f
m.r = l
m.u = f
l.q = b
l.o = e
n.r = b
n.v = e
n.t = f
f.r = l
f.u = m
e.r = b
e.v = n
e.t = f
assert e.t.r.q.p.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: B = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
l = C("l")
n = D("n")
f = B("f")
e = D("e")

b.y = f
b.p = f
m.r = l
m.u = f
l.q = b
l.o = e
n.r = b
n.v = e
n.t = f
f.r = l
f.u = m
e.r = b
e.v = n
e.t = f
assert e.t.r.q.p.r.q.txt == "b"