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

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

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

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

l = A("l")
i = B("i")
g = C("g")
f = D("f")
j = B("j")
e = A("e")
a = A("a")

l.p = g
l.q = f
l.y = a
i.t = e
g.v = f
f.q = a
f.v = i
j.t = a
e.p = g
e.q = f
e.y = a
a.p = g
a.q = f
a.y = l
assert i.t.p.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: D = None
        self.y: A = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
g = C("g")
f = D("f")
j = B("j")
e = A("e")
a = A("a")

l.p = g
l.q = f
l.y = a
i.t = e
g.v = f
f.q = a
f.v = i
j.t = a
e.p = g
e.q = f
e.y = a
a.p = g
a.q = f
a.y = l
assert i.t.p.v.q.txt == "a"