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

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

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

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

b = A("b")
e = B("e")
c = C("c")
d = D("d")
i = B("i")
k = B("k")
g = D("g")
h = D("h")
j = C("j")
f = C("f")

b.p = j
e.q = k
e.y = b
e.z = h
c.x = b
c.p = k
c.t = i
d.x = j
i.q = e
i.y = b
i.z = d
k.q = e
k.y = b
k.z = d
g.x = f
h.x = f
j.x = b
j.p = i
j.t = k
f.x = b
f.p = k
f.t = k
assert h.x.p.y.p.x.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
c = C("c")
d = D("d")
i = B("i")
k = B("k")
g = D("g")
h = D("h")
j = C("j")
f = C("f")

b.p = j
e.q = k
e.y = b
e.z = h
c.x = b
c.p = k
c.t = i
d.x = j
i.q = e
i.y = b
i.z = d
k.q = e
k.y = b
k.z = d
g.x = f
h.x = f
j.x = b
j.p = i
j.t = k
f.x = b
f.p = k
f.t = k
assert h.x.p.y.p.x.p.p.y.txt == "b"