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

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

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

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

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

f.t = n
f.x = e
f.p = h
n.y = e
j.y = n
j.w = n
j.z = f
j.q = h
l.x = b
b.t = n
b.x = l
b.p = h
h.t = n
h.x = e
h.p = b
e.x = b
a.y = n
a.w = n
a.z = b
a.q = f
assert n.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: D = None
        self.p: A = None
        self.txt = txt

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

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

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

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

f.t = n
f.x = e
f.p = h
n.y = e
j.y = n
j.w = n
j.z = f
j.q = h
l.x = b
b.t = n
b.x = l
b.p = h
h.t = n
h.x = e
h.p = b
e.x = b
a.y = n
a.w = n
a.z = b
a.q = f
assert n.y.x.x.txt == "l"