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

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

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

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

e = A("e")
l = B("l")
b = C("b")
d = D("d")
c = D("c")
f = C("f")
j = A("j")
m = C("m")

e.r = m
e.u = j
e.v = f
l.r = f
b.s = m
b.q = e
d.x = e
c.x = j
f.s = m
f.q = j
j.r = b
j.u = e
j.v = m
m.s = f
m.q = e
assert m.q.u.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: A = None
        self.v: C = None
        self.txt = txt

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

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

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

e = A("e")
l = B("l")
b = C("b")
d = D("d")
c = D("c")
f = C("f")
j = A("j")
m = C("m")

e.r = m
e.u = j
e.v = f
l.r = f
b.s = m
b.q = e
d.x = e
c.x = j
f.s = m
f.q = j
j.r = b
j.u = e
j.v = m
m.s = f
m.q = e
assert m.q.u.v.s.txt == "f"