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

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

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

h = A("h")
c = B("c")
g = C("g")
k = A("k")
d = C("d")
j = B("j")

h.q = g
h.x = j
h.y = j
c.p = k
g.s = k
g.v = d
g.x = d
k.q = d
k.x = c
k.y = j
d.s = h
d.v = g
d.x = g
j.p = k
assert c.p.x.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: B = None
        self.y: B = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
g = C("g")
k = A("k")
d = C("d")
j = B("j")

h.q = g
h.x = j
h.y = j
c.p = k
g.s = k
g.v = d
g.x = d
k.q = d
k.x = c
k.y = j
d.s = h
d.v = g
d.x = g
j.p = k
assert c.p.x.p.y.txt == "j"