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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: D = None
        self.txt = txt

c = A("c")
h = B("h")
l = C("l")
d = D("d")
m = E("m")
a = F("a")

c.r = a
h.p = d
l.x = m
l.u = c
l.p = a
d.q = l
m.w = c
a.s = h
a.p = d
assert c.r.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: D = None
        self.txt = txt

c = A("c")
h = B("h")
l = C("l")
d = D("d")
m = E("m")
a = F("a")

c.r = a
h.p = d
l.x = m
l.u = c
l.p = a
d.q = l
m.w = c
a.s = h
a.p = d
assert c.r.s.p.txt == "d"