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

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

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

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

i = A("i")
a = B("a")
d = C("d")
h = D("h")
m = D("m")
b = D("b")
n = B("n")
f = D("f")
g = D("g")

i.x = n
i.p = d
a.v = d
a.p = i
a.y = m
d.y = n
d.q = a
h.q = i
h.y = i
h.t = d
m.q = i
m.y = i
m.t = d
b.q = i
b.y = i
b.t = d
n.v = d
n.p = i
n.y = f
f.q = i
f.y = i
f.t = d
g.q = i
g.y = i
g.t = d
assert i.p.q.p.x.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: C = None
        self.txt = txt

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

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

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

i = A("i")
a = B("a")
d = C("d")
h = D("h")
m = D("m")
b = D("b")
n = B("n")
f = D("f")
g = D("g")

i.x = n
i.p = d
a.v = d
a.p = i
a.y = m
d.y = n
d.q = a
h.q = i
h.y = i
h.t = d
m.q = i
m.y = i
m.t = d
b.q = i
b.y = i
b.t = d
n.v = d
n.p = i
n.y = f
f.q = i
f.y = i
f.t = d
g.q = i
g.y = i
g.t = d
assert i.p.q.p.x.y.q.txt == "i"