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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

a = A("a")
f = B("f")
b = C("b")
j = D("j")
e = E("e")
d = A("d")
k = E("k")
l = E("l")

a.u = j
a.v = j
f.x = j
f.p = j
b.r = f
b.u = e
b.p = a
j.p = a
e.s = f
d.u = j
d.v = j
k.s = f
l.s = f
assert l.s.x.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

a = A("a")
f = B("f")
b = C("b")
j = D("j")
e = E("e")
d = A("d")
k = E("k")
l = E("l")

a.u = j
a.v = j
f.x = j
f.p = j
b.r = f
b.u = e
b.p = a
j.p = a
e.s = f
d.u = j
d.v = j
k.s = f
l.s = f
assert l.s.x.p.u.p.txt == "a"