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

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

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

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

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

b.p = d
b.v = m
b.x = f
b.y = l
j.q = m
j.u = f
d.t = f
m.q = b
m.s = b
m.p = l
l.t = j
f.q = m
f.u = j
assert j.u.u.u.q.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: D = None
        self.x: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

b.p = d
b.v = m
b.x = f
b.y = l
j.q = m
j.u = f
d.t = f
m.q = b
m.s = b
m.p = l
l.t = j
f.q = m
f.u = j
assert j.u.u.u.q.p.t.txt == "j"