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

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

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

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

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

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

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

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

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

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

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

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

f.x = g
f.p = b
b.y = f
j.p = e
j.q = d
g.q = b
a.v = j
a.x = b
a.u = g
a.q = f
a.p = f
e.v = d
e.x = b
e.u = g
e.q = f
e.p = l
l.x = g
l.p = b
d.p = e
d.q = j
assert d.p.q.x.q.y.p.txt == "b"