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

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

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

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

a = A("a")
f = B("f")
b = C("b")
h = D("h")
n = C("n")
c = A("c")
k = A("k")
j = B("j")
e = B("e")
l = D("l")

a.p = n
a.q = c
a.y = c
a.x = b
f.w = a
f.v = c
f.y = e
b.r = c
h.y = n
h.u = n
h.r = b
n.r = c
c.p = b
c.q = k
c.y = k
c.x = n
k.p = n
k.x = n
k.q = c
k.y = c
j.w = c
j.v = a
j.y = e
e.w = k
e.v = k
e.y = j
l.y = n
l.u = n
l.r = b
assert f.y.w.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: A = None
        self.y: A = None
        self.x: C = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
b = C("b")
h = D("h")
n = C("n")
c = A("c")
k = A("k")
j = B("j")
e = B("e")
l = D("l")

a.p = n
a.q = c
a.y = c
a.x = b
f.w = a
f.v = c
f.y = e
b.r = c
h.y = n
h.u = n
h.r = b
n.r = c
c.p = b
c.q = k
c.y = k
c.x = n
k.p = n
k.x = n
k.q = c
k.y = c
j.w = c
j.v = a
j.y = e
e.w = k
e.v = k
e.y = j
l.y = n
l.u = n
l.r = b
assert f.y.w.q.p.txt == "b"