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

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

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

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

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

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

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

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

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

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

i.u = l
i.p = l
i.s = j
i.y = m
c.t = m
c.s = m
m.q = l
j.t = m
j.x = m
b.t = m
b.x = m
d.t = m
d.s = m
f.t = m
f.s = m
l.u = i
l.p = i
l.s = b
l.y = m
n.t = m
n.s = m
a.t = m
a.s = m
assert f.t.q.y.q.y.q.s.txt == "b"