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

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

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

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

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

j.x = n
j.y = l
n.x = a
n.q = e
n.r = e
n.s = f
f.s = d
f.x = j
b.u = f
a.s = d
a.x = e
m.s = f
m.x = e
l.u = d
d.s = a
d.x = j
e.x = n
e.y = b
assert d.x.y.u.x.y.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

j.x = n
j.y = l
n.x = a
n.q = e
n.r = e
n.s = f
f.s = d
f.x = j
b.u = f
a.s = d
a.x = e
m.s = f
m.x = e
l.u = d
d.s = a
d.x = j
e.x = n
e.y = b
assert d.x.y.u.x.y.u.x.txt == "j"